<!DOCTYPE >
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>编辑应用</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/system/css/right.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/system/css/jquery.datetimepicker.css"/>
<script type="text/javascript" src="__PUBLIC__/system/js/jquery.js"></script>
<script type="text/javascript" src="__PUBLIC__/system/js/system.js"></script>
<script type="text/javascript" src="__PUBLIC__/system/js/ajaxupload.js"></script>
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="__PUBLIC__/system/js/jquery.datetimepicker.js"></script>
</head>
<body style="overflow: auto;">
    <div class="basic bor">
            <div class="title fl">当前位置：应用管理 >编辑应用</div>
            <div class="basic_r fr"><a href="{:U('Index/setting')}">基本信息</a></div>
    </div>
    <div class="notice">
            <div class="n_title">
                <span class="fl">编辑应用</span>
                
            </div>
            <div class="ncontent">
                <form  id = "J_editForm" method="post" enctype="multipart/form-data" >
                    <div class="setting">

                     <ul>
                        <li>
                            <dd class="setting_t fl"><span>*</span>应用标题 ：</dd>
                            <dd class="setting_p fl">
                            <input class="seinp" type="text" name="title" value="{$app.title}">
                                <span>应用标题不能为空</span>
                            </dd>
                        </li>
                        <li> 
                            <dd class="setting_t fl"><span>*</span>上传LOGO图片 ：</dd>
                            <dd class="setting_p fl">
                                <div class="infx">
                                <input class="infile" type="file" id="unloadLogoPic" name="pic"> 
                                <input type="hidden" id = "J_logo" name ="logo" value="{$app['logo']}">
                                <span class="text_s">上传文件</span>
                                </div>
                                <span>请按照当前尺寸及大小修改</span>
                            </dd>
                            <dd> 
                              <if condition="$app.logo">
                              <img src="{$app['logo']}" id="J_logo_img" style = "width:80px;background: #f1077c;" alt="">  
                              </if>
                            </dd>
                        </li> 
                        <li> 
                            <dd class="setting_t fl"><span>*</span>上传背景图片 ：</dd>
                            <dd class="setting_p fl">
                                <div class="infx">
                                <input class="infile" type="file" id = "J_back_pic" name="pic"> 
                                <input type="hidden" id = "J_background" name ="background" value ="{$app['background']}">
                                <span class="text_s">上传文件</span>
                                </div>
                                <span>请按照当前尺寸及大小修改</span>
                            </dd>
                           <dd> 
                            <if condition="$app.background">
                            <img src="{$app['background']}" id="J_back_img" style = "width:80px;background: #f1077c;" alt="">  
                            </if>
                          </dd>
                        </li> 

                        <li>
                            <dd class="setting_t fl"><span>*</span>活动开始时间：</dd>
                            <dd class="setting_p fl">
                            <input type="text" name ="start_time" id="datetimepicker1"  value = '<if condition="$app.start_time neq null">{$app.start_time}<else/>2017/01/01</if>'   />
                                <span>活动开始时间不能为空</span>
                            </dd>
                        </li>

                        <li>
                            <dd class="setting_t fl"><span>*</span>活动结束时间：</dd>
                            <dd class="setting_p fl">
                             <input type="text" name ="end_time" value = '<if condition="$app.start_time neq null">{$app.end_time}<else/>2017-01-01</if>' id="datetimepicker2"/>
                                <span>活动结束时间不能为空</span>
                            </dd>
                        </li>
                        <li>
                            <dd class="setting_t fl"><span>*</span>微信转发标题 ：</dd>
                            <dd class="setting_p fl">
                            <input class="seinp" type="text" name="wx_title" value="{$app.wx_title}">
                                <span>微信转发标题不能为空</span>
                            </dd>
                        </li>

                        <li> 
                          <dd class="setting_t fl"><span>*</span>微信转发图片:</dd>
                           <dd class="setting_p fl">
                             <div class="infx">
                                <input class="infile" type="file" id = "J_wx_upload" name="pic"> 
                                <input type="hidden" id = "J_wx_pic" name ="wx_pic" value ="{$app.wx_pic}">
                                <span class="text_s">上传文件</span>
                                </div>
                            </dd>
                             <dd> 
                              <if condition="$app.wx_pic">
                              <img src="{$app['wx_pic']}" id="J_wx_img" style = "width:80px;background: #f1077c;" alt="">  
                              </if>
                            </dd>
                        </li>
                        <li>
                            <dd class="setting_t fl">微信转发描述 ：</dd>
                            <dd class="setting_p fl">
                            <textarea name="wx_desc" class="textarea bor" >{$app.wx_desc}</textarea> 
                            </dd>
                        </li>
                       <li>
                          <dd class="setting_t fl">是否需要关注公众号 ：</dd>
                          <dd class="setting_p fl">
                          <input class="checkbox bor J_radios"  name="is_allow"  type="radio" value="1"
                           <if condition="$app.is_allow eq 1">checked="checked" </if>    />是
                          <input class="checkbox bor J_radios" name="is_allow"  type="radio" value="0"   <if condition="$app.is_allow eq 0">checked="checked" </if>/>否
                          </dd>
                      </li> 
                      <li id = "J_QRcode" style = "display:none;"> 
                          <dd class="setting_t fl"><span>*</span>上传二维码图片 ：</dd>
                          <dd class="setting_p fl">
                              <div class="infx">
                              <input class="infile" type="file" id="unloadQrcode" name="pic"> 
                              <input type="hidden" id = "J_qrcode" name ="qrcode" value="{app.qrcode}">
                              <span class="text_s">上传文件</span>
                              </div>
                              <span>请按照当前尺寸及大小修改</span>
                          </dd>
                          <dd> 
                          <if condition="$app.qrcode">
                          <img src="{$app.qrcode}" id="J_qrcode_img" style = "width:80px;background: #f1077c;" alt="">
                          </if>
                          </dd>
                        </li> 
                        <li>
                            <dd class="setting_t fl">活动介绍 ：</dd>
                            <dd class="setting_p intop fl">
                            <textarea name="intriduct" class="textarea textared" id ='container'> {$app.content}</textarea>
                            </dd>
                        </li>
                        <li>
                            <dd class="setting_t fl"> &nbsp;</dd>
                            <dd class="setting_p fl">
                            <input  type="hidden" name="pic1" value="{$catename.pic}">
                            <input  type="hidden" name="id" value="{$_GET['id']}">
                            <input class="submit" type="button" id = "J_submit" value="保存">
                                
                            </dd>
                        </li>
                    </ul>
                        

                    </div>
                    </form>
            </div>
    </div>
    <div class="ui-loading-block" id = "J_loading">
    <div class="ui-loading-cnt">
        <i class="ui-loading-bright"></i>
        <p>正在上传中...</p>
    </div>
</div>
 </script>
  <script type="text/javascript">
    $('#datetimepicker1').datetimepicker();
    $('#datetimepicker2').datetimepicker();
$(function(){
  
  $(".J_radios").click(function(){
   var is_allow = $("input[name='is_allow']:checked").val(); 
   if(is_allow ==1){
    $('#J_QRcode').show();
   }else{
    $('#J_QRcode').hide();
   }
  });
    //上传图片
 var oBtn = document.getElementById("unloadLogoPic");   
  new AjaxUpload(oBtn,{
      action: "{:U('Application/ajaxUpload')}",  
      name:"pic",
      onSubmit:function(file,ext){
        $("#J_loading").addClass('show');
          if(ext && /^(jpg|jpeg|png|gif)$/.test(ext)){
              //ext是后缀名
              oBtn.disabled = "disabled";
          }else{  
              return false;
          }
      }, 

      onComplete:function(file,response){  
         oBtn.disabled = false;
          $("#J_loading").removeClass('show');
          var res = JSON.parse(response); 
          if(res.status == 1){ 
            $("#J_logo").val(res.path);
            $("#J_logo_img").attr("src",res.path);
            
          }else{
            alert("上传失败");
          } 
      }
  });
 var oBtn1 = document.getElementById("J_back_pic");   
  new AjaxUpload(oBtn1,{
      action: "{:U('Application/ajaxUpload')}",  
      name:"pic",
      onSubmit:function(file,ext){
        $("#J_loading").addClass('show');
          if(ext && /^(jpg|jpeg|png|gif)$/.test(ext)){
              //ext是后缀名
              oBtn1.disabled = "disabled";
          }else{  
              return false;
          }
      }, 

      onComplete:function(file,response){  
        oBtn1.disabled = false;
          $("#J_loading").removeClass('show');
          var res = JSON.parse(response); 
          if(res.status == 1){ 
            $("#J_background").val(res.path);
            $("#J_back_img").attr("src",res.path); 
          }else{
            alert("上传失败");
          } 
      }
  });
  //上传微信转发封面
  var oBtn2 = document.getElementById("J_wx_upload");   
  new AjaxUpload(oBtn2,{
      action: "{:U('Application/ajaxUpload')}",  
      name:"pic",
      onSubmit:function(file,ext){
        $("#J_loading").addClass('show');
          if(ext && /^(jpg|jpeg|png|gif)$/.test(ext)){
              //ext是后缀名
              oBtn2.disabled = "disabled";
          }else{  
              return false;
          }
      }, 

      onComplete:function(file,response){  
         oBtn2.disabled = false;
          $("#J_loading").removeClass('show');
          var res = JSON.parse(response); 
          if(res.status == 1){ 
            $("#J_wx_pic").val(res.path);
            $("#J_wx_img").attr("src",res.path); 
          }else{
            alert("上传失败");
          } 
      }
  });
  
  //上传微信二维码
  var oBtn3 = document.getElementById("unloadQrcode");   
  new AjaxUpload(oBtn3,{
      action: "{:U('Application/ajaxUpload')}",  
      name:"pic",
      onSubmit:function(file,ext){
        $("#J_loading").addClass('show');
          if(ext && /^(jpg|jpeg|png|gif)$/.test(ext)){
              //ext是后缀名
              oBtn3.disabled = "disabled";
          }else{  
              return false;
          }
      }, 

      onComplete:function(file,response){  
         oBtn3.disabled = false;
          $("#J_loading").removeClass('show');
          var res = JSON.parse(response); 
          if(res.status == 1){
            alert("上传成功");
            $("#J_qrcode").val(res.path);
             $("#J_qrcode_img").attr("src",res.path); 
          }else{
            alert("上传失败");
          } 
      }
  });
  //提交表单 
  $("#J_submit").click(function(){
    var url = "{:U('Application/editStoreApp')}";
    var data = $("#J_editForm").serializeArray();
    console.log(data);
    $.ajax({
            type: "POST",
            dataType: 'json',
            async: false,
            url: url,
            data: data,
            success: function(res){
                if (res.status == '1') {
                   alert(res.info);
                   var link = "{:U('Application/index')}";
                   location.href = link;  //成功后跳转页面
                }else{
                    alert(res.info);
                }
            },
            error: function(){
            },
    });
  });
    


});
 
    </script>


</body>
</html>